{% extends 'base.html' %}
{% load staticfiles %}
{% block title %}
    我的网站|搜索
{% endblock %}

{% block header_extends %}

{% endblock %}
{% block nav_home_active %}
    active
{% endblock %}
{% block content %}


    <div class="container">
        <div class="row">
            <div class="col-md-8 col-md-offset-2">
                {% if search_words == '' %}
                    <h3>你没有搜索任何内容</h3>
                    <p>你可以尝试输入点别的东西</p>
                {% else %}
                    <h3>搜索“{{ search_words }}”，找到{{ search_blogs_count }}个结果</h3>
                    <hr>
                    {% for blog in page_of_blogs %}
                        <a href="{% url 'blog_datell' blog.pk %}">
                            {{ blog.title }}
                        </a>

                        <p>{{ blog.content | striptags|truncatechars_html:100 }}</p>
                    {% empty %}
                        <p>搜索不到任何内容</p>
                    {% endfor %}

                {% endif %}
            </div>
        </div>
        <div class="row" style="display: flex; justify-content: center;">
            {% if page_of_blogs.has_previous %}
                <a class="btn btn-default" href="{% url 'search' %}?wd={{ search_word }}&page={{ page_of_blogs.previous_page_number }}">上一页</a>
            {% endif %}
            {% if page_of_blogs.has_next %}
                <a  class="btn btn-default" href="{% url 'search' %}?wd={{ search_word }}&page={{ page_of_blogs.next_page_number }}">下一页</a>

            {% endif %}
        </div>
    </div>
{% endblock %}